package com.sc.base.admin.util;

import com.sc.base.admin.comm.entity.SysDictionaryEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 *
 * */
public class ProfitConfig {

    private static final Logger logger = LoggerFactory.getLogger(ProfitConfig.class);



    public static Map<String,String> profitCacheMap = new ConcurrentHashMap<>();


    public static void put(List<SysDictionaryEntity> dictionaryEntityList){
        for(SysDictionaryEntity sysDictionaryEntity:dictionaryEntityList){
            profitCacheMap.put(sysDictionaryEntity.getDicName(),sysDictionaryEntity.getDicValue());
        }

    }

    /**
     * 获取配置值
     * 请使用GameKey统一管理key
     * */
    public static String getValue(String  key){
        try{
            return profitCacheMap.get(key);
        }catch (Exception e){
            logger.error("ProfitConfig error: key is null:{}",key);
        }
        return "";
    }

    /**
     * 获取配置值
     * 请使用GameKey统一管理key tlbc_per_hour
     * */
    public static Integer getValueByInt(String  key){
        try{
            return Integer.parseInt(profitCacheMap.get(key));
        }catch (Exception e){
            logger.error("GGameConfig error: key is null:{}",key);
            e.printStackTrace();
        }
        return 0;
    }
}
